import request from '@/plugins/request/index_sw'

var pre = "app";

if (process.env.NODE_ENV !== "development") {
  pre = '/api/ra/realasset-flc/' + pre;
}

function queryString(params) {
  if (params == undefined || params == null || params == '') {
    params = {};
  }
  params.userid = sessionStorage.getItem("userid");
  params.corpid = JSON.parse(sessionStorage.getItem("userInfo")).orgId
  // params.userid = 'DC3FAC12E5424B8A830C65EC538DA816';
  // params.corpid = '40286c1484bdd1a1018633e717932ba7';
  let paramsData = '?';
  for (var Key in params) {
    if (params[Key] || params[Key] === 0) {
      paramsData += Key + '=' + params[Key] + '&';
    }
  }
  return paramsData.slice(0, -1);
}


function queryStrings(params) {
  if (params == undefined || params == null || params == '') {
    params = {};
  }
  let paramsData = '?';
  for (var Key in params) {
    if (params[Key] || params[Key] === 0) {
      paramsData += Key + '=' + params[Key] + '&';
    }
  }
  return paramsData.slice(0, -1);
}

// function putData(params) {
//   if (params == undefined || params == null || params == '') {
//     params = {};
//   }
//   params.userid = sessionStorage.getItem("userId");
//   params.corpid = sessionStorage.getItem("corpId");
//   return params;
// }
export function getCorpIdByUserOrg(param) {
  let str = queryStrings(param);
  return request({
    url: `${pre}/upgrade/getCorpIdByUserOrg${str}`,
    method: 'GET',
  });
}

// 上传图片
export function getUpload(param) {
  // let str = queryStrings(param);
  return request({
    url: `${pre}/upgrade/getAppVersionInfo`,
    method: 'post',
    headers: {'Content-Type': 'multipart/form-data'},
    data: param
  });
}


// 初始化主页接口数据
export function getTodoBadge(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/getTodoBadge${str}`,
    method: "GET",
  });
}

// 校验app版本
// export function getAppVersionInfo(param) {
//   let str = queryString(param);
//   return request({
//     // url: `${pre}/upgrade/getAppVersionInfo${str}`,
//     url: `${pre}/upgrade/getAppVersionInfo${str}`,
//     method: "POST",
//   });
// }


// 后勤资产总数量
export function getLabeledInfo(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/getLabeledInfo${str}`,
    method: "GET",
  });
}

// **********************楼宇信息begin**************
// 获取楼宇设备全息视图
export function getLouysbQuanxst(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/quanxstLouy/getLouysbQuanxst${str}`,
    method: "GET",
  });
}

// **********************楼宇信息end**************


// **********************查询人员begin**************
// 查询人员选择接口
export function queryWin(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/wuzpd/queryWin${str}`,
    method: "GET",
  });
}

// **********************查询人员end**************


// *******************办公物资begin**************************
// 获取办公物资信息
export function getBangwzQuanxst(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/quanxstBang/getBangwzQuanxst${str}`,
    method: "get",
  });
}

// 保存办公物资
export function saveBangwz(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/wuzpd/saveBangwz${str}`,
    method: "GET",
  });
}

// *******************办公物资end**************************


// *******************服务设备begin**************************
// 获取服务设备信息
export function getFuwsbQuanxst(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/quanxstFuw/getFuwsbQuanxst${str}`,
    method: "get",
  });
}

export function saveFuwsb(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/wuzpd/saveFuwsb${str}`,
    method: "GET",
  });
}

// *******************服务设备end**************************

// **********************公共begin**************
// 列表页
export function queryShebListByParams(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/queryShebListByParams${str}`,
    method: "GET",
  });
}

// 取消贴签(all)
export function quxtq(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/quxtq${str}`,
    method: "GET",
    // data: paramData,
  });
}

// 类型数据
export function getLbByType(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/getLbByType${str}`,
    method: "GET",
  });
}

// 获取楼宇信息(搜索)
export function getLouyByUser(param) {
  let str = queryStrings(param);
  return request({
    url: `${pre}/getLouyByUser${str}`,
    method: "GET",
  });
}

// 通过楼宇信息找到楼层信息
export function getLoucByLouy(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/getLoucByLouy${str}`,
    method: "GET",
  });
}

// 通过楼层信息找到房间信息
export function getFangjByLouc(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/getFangjByLouc${str}`,
    method: "GET",
  });
}

// **********************公共end**************


// *****************故障报修begin**********************
// 通过楼层信息找到房间信息
export function getReportHistory(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/guzbx/getReportHistory${str}`,
    method: "GET",
  });
}

// *****************故障报修end**********************


// *****************物资发放begin**********************
// 物资发放、发放清单list数据
export function queryWuzff(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/wuzff/query${str}`,
    method: "GET",
  });
}

// 物资发放list数据
export function queryFfsb(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/wuzff/queryFfsb${str}`,
    method: "GET",
  });
}

export function updateStatus(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/wuzff/updateStatus${str}`,
    method: "GET",
  });
}


// *****************物资发放end**********************/


// 坐标采集
export function getLouyList(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/zuob/getLouyList${str}`,
    method: "GET",
  });
}

// 坐标采集-更新坐标经纬度
export function updateLouyzb(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/zuob/updateLouyzb${str}`,
    method: "GET",
  });
}


// 盘点计划
export function pandjh(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/wuzpd/pandjh${str}`,
    method: "GET",
  });
}

export function pandSave(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/wuzpd/save${str}`,
    method: "GET",
  });
}

export function queryPandjg(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/wuzpd/queryPandjg${str}`,
    method: "POST",
  });
}

export function queryPandQy(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/wuzpd/queryPandQy${str}`,
    method: "GET",
  });
}

export function updateJhzt(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/wuzpd/updateJhzt${str}`,
    method: "POST",
  });
}


/**
 *  获取单位信息
 * @param param
 * @returns {AxiosPromise}
 */
export function getAllCorpMsg(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/wuzbj/getAllCorpMsg${str}`,
    method: "GET",
  });
}

export function shebxjList(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/shebxjList/${str}`,
    method: "GET",
  });
}


export function queryYffsb(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/wuzff/queryYffsb${str}`,
    method: "GET",
  });
}

export function queryXlwuzz(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/wuzff/queryXlwuzz${str}`,
    method: "GET",
  });
}


export function shebxjDuixList(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/shebxjDuixList${str}`,
    method: "GET",
  });
}


export function getSbqxList(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/getSbqxList${str}`,
    method: "GET",
  });
}


export function saveXunjjg(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/saveXunjjg${str}`,
    method: "GET",
  });
}


export function saveGuzbx(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/guzbx/saveGuzbx${str}`,
    method: "GET",
  });
}


export function shebxjHistory(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/shebxjHistory${str}`,
    method: "GET",
  });
}

export function weixHistory(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/guzbx/weixHistory${str}`,
    method: "GET",
  });
}

export function getUseridByUsercode(param) {
  return request({
    url: `${pre}/getUseridByUsercode`,
    method: "POST",
    data: param
  });
}


export function saveLouysb(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/wuzpd/saveLouysb${str}`,
    method: "GET",
  });
}

export function getDetailBySwid(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/guzbx/getDetailBySwid${str}`,
    method: "GET",
  });
}


export function updateBarcodeByDeviceId(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/updateBarcodeByDeviceId${str}`,
    method: "GET",
  });
}

export function queryCk(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/wuzth/queryCk${str}`,
    method: "GET",
  });
}

export function tuih(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/wuzth/tuih${str}`,
    method: "POST",
  });
}

export function upload(data) {
  return request({
    url: `${pre}/file/upload`,
    method: 'post',
    headers: {'Content-Type': 'multipart/form-data'},
    data: data,
  });
}

export function updateWzxx(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/wuzbj/updateWzxx${str}`,
    method: "GET",
  });
}

var bgwzPre = "";
if (process.env.NODE_ENV !== "development") {
  bgwzPre = '/api/ra/realasset-flc/';
}

//办公物资领用申请分页查询
export function bgwzQuryList(param) {
  let str = queryString(param);
  return request({
    url: `${bgwzPre}/bgwzlysq/query${str}`,
    method: "GET",
  });
}

//办公物资领用楼宇分页查询
export function queryFcWin(param) {
  let str = queryString(param);
  return request({
    url: `${bgwzPre}/louysbxx/queryFcWin${str}`,
    method: "GET",
  });
}

//办公物资领用楼层分页查询
export function queryLcWin(param) {
  let str = queryString(param);
  return request({
    url: `${bgwzPre}/bgwzxx/queryLcWin${str}`,
    method: "GET",
  });
}

//办公物资领用房间分页查询
export function queryFjWin(param) {
  let str = queryString(param);
  return request({
    url: `${bgwzPre}/bgwzxx/queryFjWin${str}`,
    method: "GET",
  });
}

//根据大类小类品名查询列表
export function getPinm(param) {
  let str = queryString(param);
  return request({
    url: `${bgwzPre}/bgwzlysq/getPinm${str}`,
    method: "GET",
  });
}

//根据大类小类品名查询列表
export function getwzxl(param) {
  let str = queryString(param);
  return request({
    url: `${bgwzPre}/bgwzxx/getwzxl${str}`,
    method: "GET",
  });
}

//保存办公物资
export function saveBgwz(param) {
  let str = queryString(param);
  return request({
    url: `${bgwzPre}/bgwzlysq/save${str}`,
    method: "POST",
  });
}

//办公物资领用申请明细基本信息
export function detail(param) {
  let str = queryString(param);
  return request({
    url: `${bgwzPre}/bgwzlysq/detail${str}`,
    method: "GET",
  });
}

//办公物资清单
export function queryLyqd(param) {
  let str = queryString(param);
  return request({
    url: `${bgwzPre}/bgwzlysq/queryLyqd${str}`,
    method: "GET",
  });
}

//审核记录
export function queryShjl(param) {
  let str = queryString(param);
  return request({
    url: `${bgwzPre}/bgwzlysq/queryShjl${str}`,
    method: "GET",
  });
}

//删除办公物资申请单
export function delData(param) {
  let str = queryString(param);
  return request({
    url: `${bgwzPre}/bgwzlysq/delData${str}`,
    method: "GET",
  });
}

//提交办公物资申请单
export function submitRecive(param) {
  let str = queryString(param);
  return request({
    url: `${bgwzPre}/bgwzlysq/updateStatus${str}`,
    method: "GET",
  });
}

//我的办公物资
export function queryMySupplies(param) {
  let str = queryString(param);
  return request({
    url: `${pre}/bgwz/queryMyBgwz${str}`,
    method: "GET",
  });
}


//查询办公物资报修信息
export function queryBgwzwxsq(param) {
  let str = queryString(param);
  return request({
    url: `${bgwzPre}/bgwzwxsq/query${str}`,
    method: "GET",
  });
}

export function queryLyqdBgwzwxsq(param) {
  let str = queryString(param);
  return request({
    url: `${bgwzPre}/bgwzwxsq/queryLyqd${str}`,
    method: "GET",
  });
}

export function detailBgwzwxsq(param) {
  let str = queryString(param);
  return request({
    url: `${bgwzPre}/bgwzwxsq/detail${str}`,
    method: "POST",
  });
}

//审核记录
export function queryBgwzwxsqShjl(param) {
  let str = queryString(param);
  return request({
    url: `${bgwzPre}/bgwzwxsq/queryShjl${str}`,
    method: "GET",
  });
}

export function queryBgwzxx(param) {
  let str = queryString(param);
  return request({
    url: `${bgwzPre}/bgwzxx/query${str}`,
    method: "GET",
  });
}

export function saveBgwzwxsq(param) {
  let str = queryString(param);
  return request({
    url: `${bgwzPre}/bgwzwxsq/save${str}`,
    method: "POST",
  });
}

export function queryFwsb(param) {
  let str = queryString(param);
  return request({
    url: `${bgwzPre}/guzbxsq/queryFwsb${str}`,
    method: "GET",
  });
}

export function guzbxsbfindAll(param) {
  let str = queryString(param);
  return request({
    url: `${bgwzPre}/guzbxsqxx/guzbxsbfindAll${str}`,
    method: "GET",
  });
}
